<template>
	<scroll-view scroll-y="true">
		<view class="commoditys-container">
			<cardShowList title="订单详情">
				<template #right>
					<text style="color: #ff4a00; font-size: 26rpx; font-weight: bold">已完成</text>
				</template>
				<view class="fs30 pl45">
					<view class="orderListLine">
						<text class="mr16 textClass">订单编号:</text>
						<text class="sf textClass">{{ order.order_no }}</text>
					</view>
					<view class="orderListLine">
						<text class="mr16 textClass">订单时间:</text>
						<text class="sf textClass">{{ order.create_time }}</text>
					</view>
					<view class="orderListLine">
						<text class="mr16 textClass">用户姓名:</text>
						<text class="sf textClass">{{ order.user.nickname }}</text>
					</view>
					<view class="orderListLine">
						<text class="mr16 textClass">设备名称:</text>
						<text class="sf textClass">{{ order.device.name }}</text>
					</view>
					<view class="orderListLine">
						<text class="mr16 textClass">设备地址:</text>
						<text class="sf textClass">{{ order.device.location }}</text>
					</view>
				</view>
			</cardShowList>
			<cardShowList title="商品列表">
				<view class="commodity">
					<view class="commodity-ls" v-for="(good, index) in expanded
              ? order.goods
              : order.goods.slice(0, 1)" :key="good.id">
						<image :src="good.banner" mode="aspectFit"></image>
						<view class="commodity-rt">
							<view class="commodity-tilte">
								{{ good.goods_name }}
							</view>
							<view class="commodity-bottom">
								<view>
									￥
									<text>{{ good.amount }}</text>
								</view>
								<text class="commodity-bottom-amount">数量:{{ good.count }}</text>
							</view>
						</view>
					</view>
					<!-- 展开提示 -->
					<view v-if="order.goods.length > 1 && !expanded" class="expand-tip" @click.stop="toggleExpand">
						<view class="gradient-overlay">
							<text class="expand-text"> 查看全部商品 </text>
							<uni-icons type="down" size="12" color="#b5b6b7" class="mb2"></uni-icons>
						</view>
					</view>
					<view v-if="order.goods.length > 1 && expanded" class="expand-tip" @click.stop="toggleExpand">
						<view class="gradient-overlay">
							<text class="expand-text">收起 </text>
							<uni-icons type="up" size="12" color="#b5b6b7" class="mb2"></uni-icons>
						</view>
					</view>
					<view class="commodity-settlement">
						共{{ waresTotal }}件商品，合计：
						<text>￥{{ order.amount }}</text>
						<view v-if="order.refund_amount !== 0">
							退款：
							<text>{{ order.refund_amount }}</text>
						</view>
					</view>
				</view>
			</cardShowList>
			<cardShowList title="购物视频" v-if="order.medias.videos.length">
				<view v-for="(item, index) in order.medias.videos" :key="index" style="display: flex; flex-direction: column; align-items: center;">
					<video id="myVideo" style="border-radius: 20rpx;" :src="item" @error="videoErrorCallback" autoplay muted object-fit="contain"
						class="mb30"></video>
				</view>
			</cardShowList>
			<view class="h100"></view>
		</view>
	</scroll-view>
</template>

<script setup>
	import {
		computed,
		onMounted,
		ref,
		defineProps
	} from "vue";
	import cardShowList from "../../../components/cardShowList/cardShowList.vue";

	const props = defineProps({
		orderDetail: {
			type: Object,
			required: true
		}
	});
	const order = ref(props.orderDetail)


	// 展开收起功能
	const expanded = ref(false);

	function toggleExpand() {
		expanded.value = !expanded.value;
	}








	const waresTotal = computed(() => {
		let sum = 0;
		if (!order.value) {
			return sum;
		}
		order.value.goods.forEach((item) => (sum += item.count));
		return sum;
	});
</script>

<style lang="scss" scoped>
	.page {
		background: #f3f3f3;
	}

	.rechargePopup {
		// background-color: #fefefe;
		width: 80vw;
		height: 70vh;
		padding: 30rpx 25rpx;
		border-radius: 20rpx;
		background: linear-gradient(to bottom, #f0e9d2 0%, #fff8df 50%, #f0e9d2 100%);

		.title {
			text-align: center;
			font-size: 38rpx;
			color: #262427;
			height: 65rpx;
			line-height: 65rpx;
			margin-bottom: 30rpx;
			border-bottom: 1px solid #f0e9d2;
		}

		.box {
			display: flex;
			justify-content: space-between;
			height: 30vh;
			padding-top: 10vh;

			.m-item {
				position: relative;
				width: 24vw;
				height: 80rpx;
				text-align: center;
				padding: 80rpx 0 20rpx;
				box-shadow: #d6d6d6 5rpx 10rpx 30rpx, -4px -4px 4px -2px #ffb70f inset;
				border-radius: 15rpx;
				color: #ffb70f;
				font-size: 40rpx;
				word-spacing: 15rpx;
				background-color: #1c211e;
				overflow: hidden;

				text {
					font-size: 27rpx;
					padding-right: 3rpx;
				}

				&:before {
					content: "";
					position: absolute;
					z-index: 99;
					transform: rotateZ(-13deg);
					top: -30rpx;
					left: -100rpx;
					height: 300rpx;
					width: 60rpx;
					background: linear-gradient(90deg,
							rgba(255, 255, 255, 0) 0%,
							rgba(255, 255, 255, 0.4) 50%,
							rgba(255, 255, 255, 0) 100%);
					animation: toright 1.5s 0s 1 ease-in-out;

					@keyframes toright {
						100% {
							left: 500rpx;
						}
					}
				}

				.send {
					content: "送50";
					position: absolute;
					z-index: 70;
					top: 0;
					left: 0;
					padding: 10rpx 14rpx;
					border-radius: 10rpx;
					background-color: #f7002f;
					color: #f3f3f3;
					font-size: 30rpx;
				}
			}

			.m-item.delay1:before {
				animation-delay: 0.5s;
			}

			.m-item.delay2:before {
				animation-delay: 1s;
			}

			.select {
				position: relative;
				background-color: #ffb70f;
				color: #1c211e;
				box-shadow: #d6d6d6 5rpx 10rpx 30rpx, -4px -4px 4px -2px #1c211e inset;
				animation: heartbeat 1.5s infinite;
				border: 3rpx solid #1c211e;

				&::after {
					content: "";
					position: absolute;
					z-index: 60;
					left: 4%;
					top: 4%;
					width: 90%;
					height: 90%;
					border-radius: 10rpx;
					border: 4rpx solid #fff8d955;
					box-sizing: border-box;
					// background-color: #333333;
				}

				@keyframes heartbeat {

					0%,
					100% {
						transform: scale(0.9);
					}

					14% {
						transform: scale(1.1);
					}

					28% {
						transform: scale(0.9);
					}

					42% {
						transform: scale(1.1);
					}

					70% {
						transform: scale(0.9);
					}
				}
			}
		}

		.button {
			position: relative;
			margin: 120rpx 40rpx 100rpx;
			background-color: #262427;
			color: #ffb70f;
			line-height: 100rpx;
			height: 100rpx;
			border-radius: 50rpx;
			text-align: center;
			font-size: 40rpx;

			&:before {
				content: "优惠";
				position: absolute;
				top: -10rpx;
				right: 10rpx;
				height: 50rpx;
				line-height: 50rpx;
				background-color: #f7002f;
				border-radius: 15rpx;
				color: #f3f3f3;
				padding: 0 15rpx;
				font-size: 28rpx;
				animation: wobble 0.8s infinite;

				@keyframes wobble {
					0% {
						transform: translateX(0%);
					}

					15% {
						transform: translateX(-25%) rotate(-5deg);
					}

					30% {
						transform: translateX(20%) rotate(3deg);
					}

					45% {
						transform: translateX(-15%) rotate(-3deg);
					}

					60% {
						transform: translateX(10%) rotate(2deg);
					}

					75% {
						transform: translateX(-5%) rotate(-1deg);
					}

					100% {
						transform: translateX(0%);
					}
				}
			}
		}
	}

	.commoditys-container {
		display: flex;
		flex-direction: column;
		align-items: center;
		background: #f3f3f3;
	}

	.view_white {
		display: flex;
		flex-direction: column;
		align-items: center;
		margin-top: 60rpx;
		background-color: #fff;
		border-radius: 10rpx;
	}

	.shop {
		width: 350rpx;
		height: 350rpx;
		background-color: red;
		position: fixed;
		top: 30%;
		left: 25%;
		border-radius: 20rpx 20rpx;
		display: flex;
		justify-content: flex-start;
		align-items: center;
		flex-direction: column;
		z-index: 40;

		.shop-ima {
			width: 300rpx;
			height: 100rpx;
			position: absolute;
			top: -50rpx;
			z-index: 40;

			image {
				width: 100%;
				height: 100%;
				border-radius: 20rpx 20rpx;
			}
		}

		.shop-top {
			font-size: 70rpx;
			font-weight: 600;
			margin-top: 60rpx;
			color: #ffda8b;
		}

		.shop-main {
			font-size: 22rpx;
			margin-top: 10rpx;
			color: #fff;
		}

		.shop-x {
			width: 80rpx;
			height: 80rpx;
			position: absolute;
			top: -80rpx;
			right: -50rpx;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.shop-bom {
			width: 80%;
			height: 80rpx;
			font-size: 40rpx;
			background-color: #ffda8b;
			border-radius: 40rpx 40rpx;
			margin-top: 25rpx;
			color: #f7002f;
			display: flex;
			justify-content: center;
			align-items: center;
		}
	}

	.commod {
		width: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;

		.commod-img {
			width: 70%;
			height: 900rpx;
			margin-top: 150rpx;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.commod-text {
			width: 60%;
			height: 100rpx;
			background-color: red;
			color: #fff;
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 35rpx;
			border-radius: 20rpx 20rpx;
			margin-top: 50rpx;
		}
	}

	// .commod{
	// 	width:700rpx;
	// 	height:500rpx;
	// 	background:#FF6F08;
	// 	position: fixed;
	// 	top:50%;
	// 	left:50%;
	// 	margin-top: -250rpx;
	// 	margin-left:-350rpx;
	// 	border-radius: 30rpx;
	// 	.commod-center{
	// 		display: flex;
	// 		justify-content: center;
	// 		align-items: center;
	// 		height:350rpx;
	// 	.commod-lt{

	// 		image{
	// 			width:300rpx;
	// 			height:200rpx;
	// 		}
	// 	}
	// 	.commod-rt{
	// 		color:#fff;
	// 		.commod-titel{
	// 			font-size: 34rpx;
	// 			font-weight: 550;
	// 			margin-bottom: 17rpx;
	// 		}
	// 		.commod-ts{
	// 			font-size: 28rpx;
	// 			margin-bottom: 22rpx;
	// 		}
	// 		image{
	// 			width:39rpx;
	// 			height:39rpx;
	// 			vertical-align: middle;
	// 		}
	// 		text{
	// 			font-size:28rpx;
	// 			margin-left: 10rpx;
	// 		}
	// 	}
	// 	}
	// 	.commod-bottom{
	// 		font-size: 34rpx;
	// 		text-align: center;
	// 		margin: 0 auto;
	// 		color:#E4FF00;
	// 		text{
	// 			display: block;
	// 		}

	// 	}
	// }

	/*如果审核走上面*/

	.notic-top {
		height: 50rpx;
		background: #fee326;
		text-align: center;

		image {
			height: 22rpx;
			width: 26rpx;
			margin-right: 12rpx;
			vertical-align: middle;
		}

		text {
			font-size: 20rpx;
			line-height: 50rpx;
		}
	}

	.commodity {
		margin-top: 22rpx;

		.commodity-ls {
			height: 150rpx;
			background: #ffffff;
			box-shadow: 0prx 5rpx 5rpx 3rpx #efefef;
			border-radius: 10rpx;
			display: flex;
			align-items: center;
			margin: 0 auto;
			margin-bottom: 10rpx;

			image {
				width: 100rpx;
				height: 100rpx;
				margin-left: 40rpx;
			}

			.commodity-rt {
				margin-left: 40rpx;
				margin-right: 40rpx;
				width: 70%;

				.commodity-tilte {
					font-size: 30rpx;
					color: #333333;
					font-weight: 550;
				}

				.specification {
					font-size: 26rpx;
					color: #333333;
					margin-top: 16rpx;
					font-weight: 550;
				}

				.commodity-bottom {
					margin-top: 30rpx;
					display: flex;
					justify-content: space-between;

					view {
						font-size: 18rpx;
						color: #fc415e;

						text {
							font-size: 28rpx;
							color: #fc415e;
						}
					}

					.commodity-bottom-amount {
						font-size: 28rpx;
						color: #c1c1c1;

					}
				}
			}
		}

		.commodity-settlement {
			height: 60rpx;
			background: #fff;
			margin: 0 auto;
			box-shadow: 0prx 5rpx 5rpx 3rpx #efefef;
			border-radius: 10rpx;
			font-size: 28rpx;
			color: #5a5a5a;
			display: flex;
			justify-content: flex-end;
			align-items: center;

			text {
				font-size: 24rpx;
				color: #fa425e;
				margin-right: 40rpx;
			}
		}
	}

	.expand-tip {
		margin-top: -40rpx;

		.gradient-overlay {
			height: 100rpx;
			background: linear-gradient(180deg,
					rgba(255, 255, 255, 0) 0%,
					rgba(255, 255, 255, 1) 100%);
			display: flex;
			justify-content: center;
			align-items: center;
		}

		.expand-text {
			color: #b5b6b7;
			font-size: 24rpx;
			margin-right: 6rpx;
		}
	}

	.orderListLine {
		margin-bottom: 18rpx;
	}

	.textClass {
		color: #5a5a5a;
		font-size: 25rpx;
	}
</style>